.class public Lcom/bitauto/autoeasy/news/Object/NewsParser;
.super Ljava/lang/Object;
.source "NewsParser.java"


# static fields
.field private static final FIRSTPICURL:Ljava/lang/String; = "FirstPicUrl"

.field private static final MODIFYTIME:Ljava/lang/String; = "PublishTime"

.field private static final NEWSID:Ljava/lang/String; = "ID"

.field private static final TAG:Ljava/lang/String; = "NewsParser"

.field private static final TITLE:Ljava/lang/String; = "Title"


# instance fields
.field private context:Landroid/content/Context;

.field private list:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/bitauto/autoeasy/news/Object/News;",
            ">;"
        }
    .end annotation
.end field

.field private url:Ljava/lang/String;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 37
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 32
    const-string v0, ""

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    .line 38
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 40
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 32
    const-string v0, ""

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    .line 41
    iput-object p1, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    .line 42
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;)V
    .locals 1
    .parameter "url"

    .prologue
    .line 44
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 32
    const-string v0, ""

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    .line 45
    iput-object p1, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    .line 46
    return-void
.end method


# virtual methods
.method public Paser2Object()V
    .locals 11

    .prologue
    const-string v10, "error :"

    const-string v9, "NewsParser"

    .line 54
    :try_start_0
    new-instance v5, Ljava/util/ArrayList;

    invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V

    iput-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    .line 55
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    invoke-static {v5}, Lcom/bitauto/autoeasy/tool/Caller;->doGet(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    .line 57
    .local v4, str:Ljava/lang/String;
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    const-string v6, "/"

    invoke-virtual {v5, v6}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 58
    const-string v5, "news00"

    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    invoke-static {v5, v4, v6}, Lcom/bitauto/autoeasy/tool/ToolBox;->savaCacheFile(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V

    .line 71
    :cond_0
    :goto_0
    new-instance v2, Lorg/json/JSONArray;

    invoke-direct {v2, v4}, Lorg/json/JSONArray;-><init>(Ljava/lang/String;)V

    .line 72
    .local v2, jArr:Lorg/json/JSONArray;
    const-string v5, "NewsParser"

    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "Length : "

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-static {v5, v6}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 73
    const/4 v1, 0x0

    .local v1, i:I
    :goto_1
    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v5

    if-lt v1, v5, :cond_6

    .line 77
    const-string v5, "NewsParser"

    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "end Parser time is :"

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v7

    invoke-virtual {v6, v7, v8}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-static {v5, v6}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 86
    .end local v1           #i:I
    .end local v2           #jArr:Lorg/json/JSONArray;
    .end local v4           #str:Ljava/lang/String;
    :goto_2
    return-void

    .line 59
    .restart local v4       #str:Ljava/lang/String;
    :cond_1
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    const-string v6, "1"

    invoke-virtual {v5, v6}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_2

    .line 60
    const-string v5, "news01"

    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    invoke-static {v5, v4, v6}, Lcom/bitauto/autoeasy/tool/ToolBox;->savaCacheFile(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Lcom/bitauto/autoeasy/tool/WSError; {:try_start_0 .. :try_end_0} :catch_1

    goto :goto_0

    .line 79
    .end local v4           #str:Ljava/lang/String;
    :catch_0
    move-exception v5

    move-object v0, v5

    .line 80
    .local v0, e:Lorg/json/JSONException;
    const-string v5, "NewsParser"

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "error :"

    invoke-direct {v5, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lorg/json/JSONException;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v9, v5}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 81
    const/4 v5, 0x0

    iput-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    .line 82
    invoke-virtual {v0}, Lorg/json/JSONException;->printStackTrace()V

    goto :goto_2

    .line 61
    .end local v0           #e:Lorg/json/JSONException;
    .restart local v4       #str:Ljava/lang/String;
    :cond_2
    :try_start_1
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    const-string v6, "2"

    invoke-virtual {v5, v6}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_3

    .line 62
    const-string v5, "news02"

    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    invoke-static {v5, v4, v6}, Lcom/bitauto/autoeasy/tool/ToolBox;->savaCacheFile(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V
    :try_end_1
    .catch Lorg/json/JSONException; {:try_start_1 .. :try_end_1} :catch_0
    .catch Lcom/bitauto/autoeasy/tool/WSError; {:try_start_1 .. :try_end_1} :catch_1

    goto/16 :goto_0

    .line 83
    .end local v4           #str:Ljava/lang/String;
    :catch_1
    move-exception v5

    move-object v0, v5

    .line 84
    .local v0, e:Lcom/bitauto/autoeasy/tool/WSError;
    const-string v5, "NewsParser"

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "error :"

    invoke-direct {v5, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lcom/bitauto/autoeasy/tool/WSError;->getMessage()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v9, v5}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_2

    .line 63
    .end local v0           #e:Lcom/bitauto/autoeasy/tool/WSError;
    .restart local v4       #str:Ljava/lang/String;
    :cond_3
    :try_start_2
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    const-string v6, "3"

    invoke-virtual {v5, v6}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_4

    .line 64
    const-string v5, "news03"

    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    invoke-static {v5, v4, v6}, Lcom/bitauto/autoeasy/tool/ToolBox;->savaCacheFile(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V

    goto/16 :goto_0

    .line 65
    :cond_4
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    const-string v6, "4"

    invoke-virtual {v5, v6}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_5

    .line 66
    const-string v5, "news04"

    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    invoke-static {v5, v4, v6}, Lcom/bitauto/autoeasy/tool/ToolBox;->savaCacheFile(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V

    goto/16 :goto_0

    .line 67
    :cond_5
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    const-string v6, "5"

    invoke-virtual {v5, v6}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 68
    const-string v5, "news05"

    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->context:Landroid/content/Context;

    invoke-static {v5, v4, v6}, Lcom/bitauto/autoeasy/tool/ToolBox;->savaCacheFile(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V

    goto/16 :goto_0

    .line 74
    .restart local v1       #i:I
    .restart local v2       #jArr:Lorg/json/JSONArray;
    :cond_6
    invoke-virtual {v2, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v5

    invoke-virtual {p0, v5}, Lcom/bitauto/autoeasy/news/Object/NewsParser;->createNews(Lorg/json/JSONObject;)Lcom/bitauto/autoeasy/news/Object/News;

    move-result-object v3

    .line 75
    .local v3, news:Lcom/bitauto/autoeasy/news/Object/News;
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    invoke-virtual {v5, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_2
    .catch Lorg/json/JSONException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Lcom/bitauto/autoeasy/tool/WSError; {:try_start_2 .. :try_end_2} :catch_1

    .line 73
    add-int/lit8 v1, v1, 0x1

    goto/16 :goto_1
.end method

.method public Paser2ObjectByCache(Ljava/lang/String;)V
    .locals 9
    .parameter "url"

    .prologue
    const-string v8, "NewsParser"

    .line 90
    :try_start_0
    new-instance v5, Ljava/util/ArrayList;

    invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V

    iput-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    .line 91
    const-string v4, ""

    .line 92
    .local v4, str:Ljava/lang/String;
    const-string v5, "/"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 93
    const-string v4, "news00"

    .line 106
    :cond_0
    :goto_0
    new-instance v2, Lorg/json/JSONArray;

    invoke-static {v4}, Lcom/bitauto/autoeasy/tool/ToolBox;->readCacheFile(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v2, v5}, Lorg/json/JSONArray;-><init>(Ljava/lang/String;)V

    .line 107
    .local v2, jArr:Lorg/json/JSONArray;
    const-string v5, "NewsParser"

    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "Length : "

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-static {v5, v6}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 108
    const/4 v1, 0x0

    .local v1, i:I
    :goto_1
    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v5

    if-lt v1, v5, :cond_6

    .line 117
    .end local v1           #i:I
    .end local v2           #jArr:Lorg/json/JSONArray;
    .end local v4           #str:Ljava/lang/String;
    :goto_2
    return-void

    .line 94
    .restart local v4       #str:Ljava/lang/String;
    :cond_1
    const-string v5, "1"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_2

    .line 95
    const-string v4, "news01"

    goto :goto_0

    .line 96
    :cond_2
    const-string v5, "2"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_3

    .line 97
    const-string v4, "news02"

    goto :goto_0

    .line 98
    :cond_3
    const-string v5, "3"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_4

    .line 99
    const-string v4, "news03"

    goto :goto_0

    .line 100
    :cond_4
    const-string v5, "4"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_5

    .line 101
    const-string v4, "news04"

    goto :goto_0

    .line 102
    :cond_5
    const-string v5, "5"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 103
    const-string v4, "news05"

    goto :goto_0

    .line 109
    .restart local v1       #i:I
    .restart local v2       #jArr:Lorg/json/JSONArray;
    :cond_6
    invoke-virtual {v2, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v5

    invoke-virtual {p0, v5}, Lcom/bitauto/autoeasy/news/Object/NewsParser;->createNews(Lorg/json/JSONObject;)Lcom/bitauto/autoeasy/news/Object/News;

    move-result-object v3

    .line 110
    .local v3, news:Lcom/bitauto/autoeasy/news/Object/News;
    iget-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    invoke-virtual {v5, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    .line 108
    add-int/lit8 v1, v1, 0x1

    goto :goto_1

    .line 112
    .end local v1           #i:I
    .end local v2           #jArr:Lorg/json/JSONArray;
    .end local v3           #news:Lcom/bitauto/autoeasy/news/Object/News;
    .end local v4           #str:Ljava/lang/String;
    :catch_0
    move-exception v5

    move-object v0, v5

    .line 113
    .local v0, e:Lorg/json/JSONException;
    const-string v5, "NewsParser"

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "error :"

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lorg/json/JSONException;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v8, v5}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 114
    const/4 v5, 0x0

    iput-object v5, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    .line 115
    invoke-virtual {v0}, Lorg/json/JSONException;->printStackTrace()V

    goto :goto_2
.end method

.method public createNews(Lorg/json/JSONObject;)Lcom/bitauto/autoeasy/news/Object/News;
    .locals 5
    .parameter "obj"

    .prologue
    .line 126
    new-instance v1, Lcom/bitauto/autoeasy/news/Object/News;

    invoke-direct {v1}, Lcom/bitauto/autoeasy/news/Object/News;-><init>()V

    .line 128
    .local v1, news:Lcom/bitauto/autoeasy/news/Object/News;
    :try_start_0
    const-string v2, "Title"

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/News;->setTitle(Ljava/lang/String;)V

    .line 129
    const-string v2, "FirstPicUrl"

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/News;->setFirstPicUrl(Ljava/lang/String;)V

    .line 130
    const-string v2, "PublishTime"

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/bitauto/autoeasy/tool/ToolBox;->String2Date(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/News;->setModifytime(Ljava/lang/String;)V

    .line 131
    const-string v2, "ID"

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/News;->setNewsid(Ljava/lang/String;)V
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    move-object v2, v1

    .line 136
    :goto_0
    return-object v2

    .line 133
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 134
    .local v0, e:Lorg/json/JSONException;
    const-string v2, "NewsParser"

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "error :"

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lorg/json/JSONException;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 135
    invoke-virtual {v0}, Lorg/json/JSONException;->printStackTrace()V

    .line 136
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public getList()Ljava/util/ArrayList;
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/bitauto/autoeasy/news/Object/News;",
            ">;"
        }
    .end annotation

    .prologue
    .line 141
    iget-object v0, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->list:Ljava/util/ArrayList;

    return-object v0
.end method

.method public setUrl(Ljava/lang/String;)V
    .locals 0
    .parameter "url"

    .prologue
    .line 49
    iput-object p1, p0, Lcom/bitauto/autoeasy/news/Object/NewsParser;->url:Ljava/lang/String;

    .line 50
    return-void
.end method
